﻿using Company.Logger;
using System.Configuration;
using System.Data;
using System.Windows;

namespace Shell
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        public App()
        {
            // 程序域异常
            AppDomain.CurrentDomain.UnhandledException += (s, e) =>
            {
                Logs.LogError((Exception)e.ExceptionObject);
            };

            // 应用程序异常
            Application.Current.DispatcherUnhandledException += (s, e) =>
            {
                Logs.LogError(e.Exception);
            };

            // 多线程异常
            TaskScheduler.UnobservedTaskException += (s, e) =>
            {
                Logs.LogError(e.Exception);
            };
        }

        protected override void OnStartup(StartupEventArgs e)
        {
            Logs.LogInfo("应用程序启动！");
            base.OnStartup(e);
            AppStartup appStartup = new AppStartup();
            appStartup.Run();
        }

        protected override void OnExit(ExitEventArgs e)
        {
            base.OnExit(e);
            Logs.LogInfo("应用程序退出！");
        }
    }

}
